home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / telecom / term_4.1 / extras / hydracom / source / hydracom.c < prev    next >
C/C++ Source or Header  |  1994-11-17  |  29KB  |  751 lines

  1. /*=============================================================================
  2.  
  3.                               HydraCom Version 1.00
  4.  
  5.                          A sample implementation of the
  6.                    HYDRA Bi-Directional File Transfer Protocol
  7.  
  8.                              HydraCom was written by
  9.                    Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
  10.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  11.  
  12.                        The HYDRA protocol was designed by
  13.                  Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
  14.                              Joaquim H. Homrighausen
  15.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  16.  
  17.  
  18.   Revision history:
  19.   06 Sep 1991 - (AGL) First tryout
  20.   .. ... .... - Internal development
  21.   11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
  22.  
  23.  
  24.   DISCLAIMER
  25.  
  26.   This program is provided "as is" and comes with no warranties of any
  27.   kind, either expressed or implied. In no event shall the authors be
  28.   liable to you or anyone else for any damages, including any lost
  29.   profits, lost savings or other incidental or consequential damages
  30.   arising out of the use or inability to use this software.
  31.  
  32.  
  33.   HYDRACOM / SOURCE LICENSE
  34.  
  35.   HydraCom, its associated utilities (HydraCfg) and the HydraCom
  36.   sourcecode may be freely distributed, copied and used, no fee charged.
  37.   All files, executables and sourcecode remain the copyrighted property
  38.   of Arjen G. Lentz and LENTZ SOFTWARE-DEVELOPMENT.
  39.   The distribution archives should remain intact with no files removed
  40.   or modified. For special purposes, it is allowed to repack the
  41.   archives using a different compression system.
  42.  
  43.   HydraCom may be bundled up with for instance terminal or BBS packages,
  44.   even commercial ones, provided the buyer/user is clearly informed
  45.   about the fact that Hydra and HydraCom are free, not owned by the
  46.   distributor/retailer in question, and is not included in any possible
  47.   charge regarding the rest of the package. This documentation must also
  48.   be present so the user can inform himself about Hydra and HydraCom.
  49.   The same rules apply to inclusion in shareware and CD-ROM libraries.
  50.   In all cases, the author of HydraCom must be given credit in any
  51.   informational screens and literature that contain such information.
  52.  
  53.   The Hydra/HydraCom sourcecode may also be freely used and integrated
  54.   into other software or library, provided this is clearly stated in any
  55.   informational screens and literature pertaining to this program, and
  56.   credit is given to the original author. If the sourcecode of that
  57.   program or library is released or otherwise published, the notices
  58.   present at the top of every Hydra/HydraCom source file must be
  59.   retained in their original unmodified form.
  60.  
  61.   In addition to the above license, everyone using any part of the
  62.   sourcecode, programs or files is fully bound by the general license of
  63.   the Hydra protocol as present in the Hydra protocol description
  64.   document. For easy reference, the paragraph in question is reprinted
  65.   below.
  66.  
  67.   Any use of, or operation on (including copying/distributing) any of
  68.   the above mentioned files implies full and unconditional acceptance of
  69.   this license and disclaimer.
  70.  
  71.  
  72.   HYDRA PROTOCOL LICENSE 
  73.  
  74.   You are granted a license to implement the HYDRA file transfer
  75.   protocol, HYDRA hereafter, in your own programs and/or use the sample
  76.   source code and adapt these to your particular situation and needs;
  77.   subject to the following conditions:
  78.  
  79.    -  You must refer to it as the HYDRA file transfer protocol, and you
  80.       must give credit to the authors of HYDRA in any information
  81.       screens or literature pertaining to your programs that contains
  82.       other such information (credits, your own copyrights, etc.).
  83.  
  84.    -  HYDRA will always remain backwards compatible with previous
  85.       revisions. HYDRA allows for expansion of its features without
  86.       interfering with previous revisions. It is, however, important
  87.       that different people do not expand the protocol in different
  88.       directions. We therefore ask you to contact us if you have any
  89.       needs/ideas regarding HYDRA, so development can be synchronized
  90.       and beneficial to all.
  91.  
  92.    -  If your implementation cannot converse with past or future
  93.       revisions as supplied by us, then you must refer to it as "HYDRA
  94.       derived", or as "a variation of HYDRA", or words to that effect.
  95.  
  96.  
  97.   Hydra protocol design and HydraCom driver:         Hydra protocol design:
  98.   Arjen G. Lentz                                     Joaquim H. Homrighausen
  99.   LENTZ SOFTWARE-DEVELOPMENT                         389, route d'Arlon
  100.   Langegracht 7B                                     L-8011 Strassen
  101.   3811 BT  Amersfoort                                Luxembourg
  102.   The Netherlands
  103.   FidoNet 2:283/512, AINEX-BBS +31-33-633916         FidoNet 2:270/17
  104.   arjen_lentz@f512.n283.z2.fidonet.org               joho@ae.lu
  105.  
  106.   Please feel free to contact us at any time to share your comments about our
  107.   software and/or licensing policies.
  108.  
  109. =============================================================================*/
  110.  
  111. #define MAIN
  112. #include "hydracom.h"
  113.  
  114.  
  115. void main (int argc, char *argv[])
  116. {
  117.         FILE    *ctl;
  118.         char     ctlname[PATHLEN];
  119.         int      err = 0;              /* assume all went well: errorlevel 0 */
  120.         int      ac;
  121.         char    *p;
  122.         register int i, res;
  123.  
  124.         av = (char **) malloc(MAXARGS * ((int) sizeof (char *)));
  125.         port = 0;                                   /* default configuration */
  126.         strcpy(device,"serial.device");    /* OLSEN */
  127.         cur_speed = com_speed = 0U;
  128.         parity = false;
  129.         noinit = nocarrier = dropdtr = false;
  130.         nobell = false;
  131.         mailer = false;
  132.         hdxsession = nooriginator = false;
  133.         hydra_txwindow = hydra_rxwindow = 0L;
  134.         flowflags = 0;
  135.         dcdmask = 0x80;
  136.         noresume = nostamp = false;
  137.         hydra_options = 0x0L;
  138.         result = opuslog = NULL;
  139.         download = "";
  140.         single_file[0] = '\0';
  141.         single_done = false;
  142.         logfp = NULL;
  143.         loglevel = 2;
  144.         opustask = -1;
  145.         didsome = false;
  146. #if !WIN_AGL
  147.         file_x = 0;
  148. #endif
  149.  
  150. #ifndef AMIGA
  151.         signal(SIGINT,SIG_IGN);                            /* disable Ctrl-C */
  152. #endif    /* AMIGA */
  153.  
  154.         if (!getenv("TZ"))
  155.            putenv("TZ=GMT0");
  156.         tzset();
  157.         dos_sharecheck();
  158.  
  159. #if !WIN_AGL && !defined(AMIGA)
  160. /* HJW The Topspeed gettext and puttext window procedures do have a
  161.    bug in non video mode, at least in version 3.02. The only thing we
  162.    can do is to enable direct viodeo. Also: The clipping window
  163.    module reports always 25 x 80 as the screen dimensions. The bugs
  164.    are reported to JPI
  165. */
  166.  
  167. #ifdef _JPI_
  168.         directvideo = 1;
  169. #else
  170.         directvideo = 0;
  171. #endif
  172. #endif
  173.  
  174.         cprint("%s %s %s; Sample implementation of Hydra revision %03u (%s)\n",
  175.               PRGNAME, VERSION, HC_OS, H_REVISION, h_revdate(H_REVSTAMP));
  176.         cprint("COPYRIGHT (C) 1991-1993 by Arjen G. Lentz; ALL RIGHTS RESERVED\n");
  177.         cprint("HYDRA was designed by Arjen G. Lentz & Joaquim H. Homrighausen\n");
  178.         cprint("\n");
  179.         cprint("Full specifications of the Hydra file transfer protocol are freely available.\n");
  180.         cprint("The sources of this driver have also been released, to which the same license\n");
  181.         cprint("applies as for this executable. See the documentation for further information.\n");
  182.         cprint("\n");
  183.  
  184. #ifndef AMIGA
  185.         if (_osmajor < 3) {
  186.            cprint("Sorry, %s requires DOS 3.0 or higher!\n",PRGNAME);
  187.            exit (2);
  188.         }
  189. #endif    /* AMIGA */
  190.  
  191.         if (argc < 2) {
  192.            cprint("Usage: %s [port N] [device <name>] [speed N] [<options> ...] <command> [<parms> ...]\n",PRGNAME);    /* OLSEN */
  193.            any_key();
  194.            cprint("options:  port N          Comport [1..16] (default COM1)\n");
  195.            cprint("          speed N         Com-speed [300..57600] (default current speed)\n");
  196.            cprint("          device <name>   Name of serial device driver to use\n");    /* OLSEN */
  197.            cprint("          line N          Actual line speed